using System.Linq;
using System.Numerics;
using NUnit.Framework;
using ProjectEuler.Core.Helpers;

namespace ProjectEuler.Core
{
    public class Problem48 : IProjectEulerProblem
    {
        protected BigInteger GetSeriesSum(int n)
        {
            var t = new BigInteger(0);
            for(int i=1;i<=n;i++)
            {
                t += BigInteger.Pow(i, i);
            }
            return t;
        }

        public int Number
        {
            get { return 48; }
        }

        public string Description
        {
            get { return "Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000."; }
        }

        public string Answer
        {
            get { return string.Join("", GetSeriesSum(1000).ToString().Reverse().Take(10).Reverse()); }
        }
    }

    [TestFixture]
    public class Problem48Tests: Problem48
    {
        [Test]
        public void Test_given_series()
        {
            Assert.AreEqual(new BigInteger(10405071317), GetSeriesSum(10));
        }
    }
}